import {
    input,
} from '@/css/DialogsCss.module.scss';

export default {
    title: '客户导入',
    dialog: {
        width: 600,
        type: 'dialog'
    },
    onMounted: [{
        action: 'print',
        value: '$params'
    }, {
        action: 'set',
        target: '$view',
        field: 'title',
        value: '$params.title'
    }, {
        action: 'set',
        target: '$widgets.form',
        field: 'value',
        value: '$params.form'
    }],
    items: [
        {
            region: 'center',
            layout: 'vertical',
            items: [
                {
                    layout: 'vertical',
                    items: [
                        {
                            id: 'form',
                            widget: 'form',
                            fields: [
                                {
                                    class: input,
                                    itemId: 'source_uuid',
                                    placeholder: '请选择客户来源',
                                    widget: 'select',
                                    dictionary: {
                                        path: 'system/dictionary/config/list',
                                        params: {
                                            module: 'system_module',
                                            name: 'crm_customer_source',
                                        }
                                    },
                                    label: '客户来源',
                                }, {
                                    itemId: 'module',
                                    value: 'crm_customer_pool'
                                }, {
                                    itemId: 'name',
                                    value: 'temp_pool'
                                }, {
                                    itemId: 'upload_uuid',
                                    value: ''
                                }
                            ],
                            buttons: [
                                {
                                    value: '上传文件',
                                    type: 'primary',
                                    onClick: [
                                        {
                                            var: 'upload',
                                            target: '$widget',
                                            action: 'upload',
                                            method: 'getValue'
                                        }, {
                                            action: 'set',
                                            target: '$widgets.form',
                                            field: 'value',
                                            value: {
                                                'upload_uuid': '$vars.upload.unique_id'
                                            }
                                        }
                                    ]
                                }, {
                                    value: '保存',
                                    type: 'primary',
                                    onClick: [
                                        {
                                            action: 'confirm',
                                            title: '表单保存',
                                            message: '是否保存表单?',
                                            confirm: [
                                                {
                                                    var: 'value',
                                                    target: '$widget',
                                                    action: 'call',
                                                    method: 'getValue'
                                                }, {
                                                    action: 'print',
                                                    value: '$vars.value',
                                                }, {
                                                    action: 'service',
                                                    path: 'customers_pool/temporary/import_record/import',
                                                    params: {
                                                        source_uuid: '$params.source_uuid',
                                                        '...': ['$vars.value']
                                                    }
                                                }, {
                                                    action: 'dialog-hide',
                                                    mode: 'apply'
                                                }
                                            ]
                                        }
                                    ]
                                }
                            ],
                            flex: true
                        }
                    ]
                }
            ]
        }
    ]
};


